/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sn.gandal.mobile.kalpet.persistence;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

/**
 * @version V 1.0 01/03/2010
 * @author SOWDIOMYERO
 */
@Entity
@Table(name = "account", catalog = "kmobile", schema = "", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"cni"})})
@NamedQueries({
    @NamedQuery(name = "Account.findAll", query = "SELECT a FROM Account a"),
    @NamedQuery(name = "Account.findById", query = "SELECT a FROM Account a WHERE a.id = :id"),
    @NamedQuery(name = "Account.findByNom", query = "SELECT a FROM Account a WHERE a.nom = :nom"),
    @NamedQuery(name = "Account.findByPrenom", query = "SELECT a FROM Account a WHERE a.prenom = :prenom"),
    @NamedQuery(name = "Account.findBySexe", query = "SELECT a FROM Account a WHERE a.sexe = :sexe"),
    @NamedQuery(name = "Account.findByAdresse", query = "SELECT a FROM Account a WHERE a.adresse = :adresse"),
    @NamedQuery(name = "Account.findByTel", query = "SELECT a FROM Account a WHERE a.tel = :tel"),
    @NamedQuery(name = "Account.findByCni", query = "SELECT a FROM Account a WHERE a.cni = :cni"),
    @NamedQuery(name = "Account.findByEnabled", query = "SELECT a FROM Account a WHERE a.enabled = :enabled"),
    @NamedQuery(name = "Account.findByNumeroClientAndCodeSecret", query = "SELECT a FROM Account a WHERE a.numeroClient = :numeroClient AND a.codeSecret= :codeSecret"),
    @NamedQuery(name = "Account.findByCodeSecret", query = "SELECT a FROM Account a WHERE a.codeSecret = :codeSecret"),
    @NamedQuery(name = "Account.findByType", query = "SELECT a FROM Account a WHERE a.type = :type"),
    @NamedQuery(name = "Account.findByDateCreated", query = "SELECT a FROM Account a WHERE a.dateCreated = :dateCreated")})
public class Account implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @Basic(optional = false)
    @Column(name = "nom", nullable = false, length = 20)
    private String nom;
    @Basic(optional = false)
    @Column(name = "prenom", nullable = false, length = 30)
    private String prenom;
    @Basic(optional = false)
    @Column(name = "sexe", nullable = false, length = 2)
    private String sexe;
    @Basic(optional = false)
    @Column(name = "adresse", nullable = false, length = 50)
    private String adresse;
    @Basic(optional = false)
    @Column(name = "tel", nullable = false, length = 20)
    private String tel;
    @Column(name = "cni", length = 20)
    private String cni;
    @Basic(optional = false)
    @Column(name = "enabled", nullable = false)
    private boolean enabled;
    @Column(name = "numeroClient")
    private Integer numeroClient;
    @Column(name = "codeSecret")
    private Integer codeSecret;
    @Basic(optional = false)
    @Column(name = "type", nullable = false, length = 3)
    private String type;
    @Basic(optional = false)
    @Column(name = "dateCreated", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateCreated;
    @JoinColumn(name = "compteCredit", referencedColumnName = "id")
    @ManyToOne(fetch = FetchType.LAZY)
    private CompteCredit compteCredit;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "account", fetch = FetchType.LAZY)
    private Credentials credentials;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "account", fetch = FetchType.LAZY)
    private List<CodeUtilisateur> codeUtilisateurList;

    public Account() {
    }

    public Account(Integer id) {
        this.id = id;
    }

    public Account(Integer id, String nom, String prenom, String sexe, String adresse, String tel, boolean enabled, String type, Date dateCreated) {
        this.id = id;
        this.nom = nom;
        this.prenom = prenom;
        this.sexe = sexe;
        this.adresse = adresse;
        this.tel = tel;
        this.enabled = enabled;
        this.type = type;
        this.dateCreated = dateCreated;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getPrenom() {
        return prenom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    public String getSexe() {
        return sexe;
    }

    public void setSexe(String sexe) {
        this.sexe = sexe;
    }

    public String getAdresse() {
        return adresse;
    }

    public void setAdresse(String adresse) {
        this.adresse = adresse;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getCni() {
        return cni;
    }

    public void setCni(String cni) {
        this.cni = cni;
    }

    public boolean getEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public Integer getNumeroClient() {
        return numeroClient;
    }

    public void setNumeroClient(Integer numeroClient) {
        this.numeroClient = numeroClient;
    }

    public Integer getCodeSecret() {
        return codeSecret;
    }

    public void setCodeSecret(Integer codeSecret) {
        this.codeSecret = codeSecret;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Date getDateCreated() {
        return dateCreated;
    }

    public void setDateCreated(Date dateCreated) {
        this.dateCreated = dateCreated;
    }

    public CompteCredit getCompteCredit() {
        return compteCredit;
    }

    public void setCompteCredit(CompteCredit compteCredit) {
        this.compteCredit = compteCredit;
    }

    public Credentials getCredentials() {
        return credentials;
    }

    public void setCredentials(Credentials credentials) {
        this.credentials = credentials;
    }

    public List<CodeUtilisateur> getCodeUtilisateurList() {
        return codeUtilisateurList;
    }

    public void setCodeUtilisateurList(List<CodeUtilisateur> codeUtilisateurList) {
        this.codeUtilisateurList = codeUtilisateurList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Account)) {
            return false;
        }
        Account other = (Account) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "sn.gandal.mobile.kalpet.persistence.Account[id=" + id + "]";
    }

}
